using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using CSP.Model.CSP;

namespace CSP.DataAccess.Mapping
{
    public class AuthenticationMap : EntityTypeConfiguration<Authentication>
    {
        public AuthenticationMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Username)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Filepath)
                .HasMaxLength(200);

            this.Property(t => t.Filename)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Authentication");
            this.Property(t => t.Id).HasColumnName("id");
            this.Property(t => t.Username).HasColumnName("username");
            this.Property(t => t.Name).HasColumnName("name");
            this.Property(t => t.Filepath).HasColumnName("filepath");
            this.Property(t => t.Filename).HasColumnName("filename");
            this.Property(t => t.Status).HasColumnName("status");
            this.Property(t => t.CertificateType).HasColumnName("certificateType");
        }
    }
}
